<?php
include_once '../../__global.php';

class aj_getBriefAttByRid extends ml_controller
{
    private $_att;
    private $_rid;
    private $_oid;
    private $_aid;
    private $_begin = 0;
    private $_num = 10;
    
    function initParam() {
        
        $this->_rid = $this->input('rid','G',0);
        $this->_att = $this->input('att','G',null);
        $this->_oid = $this->input('oid','G',0);
        $this->_aid = $this->__visitor['uid'];
    }
    
    function checkParam() {
        $this->check_referer();
        if (!ml_tool_resid::is_resid($this->_rid)) {
            $this->api_output(ML_RCODE_PARAM);
        }
        
        if (!ml_tool_isuid::is_mluid($this->_oid)) {
            $this->api_output(ML_RCODE_PARAM);
        }
        
        if (!ml_tool_resid::resid2uid($this->_rid) == $this->_oid) {
            $this->api_output(ML_RCODE_PARAM);
        }
        
    }
    
    function main() {
            
        $oLikeMe = new ml_model_dbLikeMe();
        $rs = $oLikeMe->getListByRid($this->_oid, $this->_rid, $this->_begin, $this->_num, $this->_att, $list);
        if (!$rs) {
            $this->api_output(ML_RCODE_BUSY);
        }
        
        $oUAcount = new ml_model_dbUserAccount();
        $dataU = array();
                
        foreach ($list as $value) {

            $rs = $oUAcount->getAccountById($value['act_uid']);
            $user['nick'] = $rs? $rs['nickname'] : '';
            
            $user['uid'] = $value['act_uid'];
            $user['headPic'] = ml_tool_picid::pid2url($value['act_uid'], ML_HEADER_PICSIZE_50, ML_PICTYPE_HEADER);
            $user['atti'] = $value['attitude'];
            
            $dataU[] = $user;
        }
        
        
        $data['result'] = $dataU;
        $data['rid'] = $this->_rid;
        $this->api_output(ML_RCODE_SUCC, $data);
        
        
    }
    
    
}

new aj_getBriefAttByRid();